package com.wjbgn.electronicnian.enums;

/**
 * Description: 公共通用枚举返回
 * Create Date: 2020/6/19
 * Modified By：<br>
 * Modified Date：<br>
 * Why & What is modified：<br>
 *
 * @author weirx
 * @version 1.0
 */
public enum CommonReturnEnum {

    SUCCESS(0, "操作成功"),

    FAILED(500, "操作失败"),

    NO_OTHER_NIAN(201, "没有其他小伙伴加入呢"),

    NO_DUMPLINGS(202, "小伙伴没有饺子，白来一趟[0.o]"),

    NO_WORDS(203, "小伙伴没有学会一句话，白来一趟[0.o]"),

    TAKE_A_WORDS(204, "带句话"),

    NO_SELF_WORDS(205, "我还没有饺子，可以教我说话，或者去串门，获得饺子哦~~"),

    SO_HUNGRY_BYE(206, "我太饿了主人，我走了，你根本养不起我~~"),

    TIGER_BYE(207, "老虎饿跑了"),

    DUMPLINGS(200, "获得");


    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    private int code;

    private String name;

    CommonReturnEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * @description: 根据code获取name
     *
     * @param code
     * @return java.lang.String
     * @author weirx
     * @date 2020/6/19
     */
    public static String getNameByCode(String code) {
        for (CommonReturnEnum platformFree : CommonReturnEnum.values()) {
            if (code.equals(platformFree.getCode())) {
                return platformFree.getName();
            }
        }
        return null;
    }

}
